﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>添加报表</title>
<base href="<%=request.getContextPath()%>/"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/adminStyle.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
 <div class="wrap">
  <div class="page-title">
    <span class="modular fl"><i class="user"></i><em>修改报表</em></span>
    <span class="modular fr"><a href="reports/list" class="pt-link-btn">返回报表列表</a></span>
  </div>
  
  <form:form action="reports/update" method="post" modelAttribute="reports" enctype="multipart/form-data">
  <table class="noborder">
   <tr>
	    <td>
	    	<input type="hidden" name="reportId" value="${reports.reportId}" class="textBox length-middle"/>
	    </td>
   </tr>
   <tr>
	    <td style="width:15%;text-align:right;">报表名称：</td>
	    <td>
	    	<input type="text" name="reportName" value="${reports.reportName}" class="textBox length-middle"/>
	    </td>
   </tr>
    <tr>
    	<td style="width:15%;text-align:right;">报表类型：</td>
    	<td>
    		 <select name="type.typeId" class="textBox length-middle">
     			<c:forEach items="${type}" var="type">
     				<c:choose>
     					<c:when test="${type.typeId==reports.type.typeId}">
     					<option value="${type.typeId}" selected="selected">${type.typeName}</option>
     					</c:when>
     					<c:otherwise>
     						<option value="${type.typeId}">${type.typeName}</option>
     					</c:otherwise>
     				</c:choose>
     			</c:forEach>
     		</select>
    	</td>
   </tr>
    <tr>
   		<td style="width:15%;text-align:right;">报表内容：</td>
   		<td style="width:85%;"><form:textarea path="reportContent"   cssClass="ckeditor"/></td>
   </tr>
   
   <tr>
	    <td style="width:15%;text-align:right;">报表图片：</td>
	    <td><input name="file" type="file" onchange="selImage(this)"/></td>
   </tr>
   <tr>
   		<td colspan="2" style="height:200px;">
				<img alt="" id="img" src="" height="150px">
		</td>
	</tr>
   <tr>
	    <td style="width:15%;text-align:right;">创建人：</td>
	    <td><input type="text" value="${reports.creator}" readonly="readonly" name="creator" class="textBox length-middle"/></td>
   		<td style="width:15%;text-align:right;">发布时间：</td>
	    <td><input type="datetime" value="<fmt:formatDate value="${reports.reportTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" name="reportTime" class="textBox length-middle"/></td>
   </tr>
   <tr>
	    <td style="width:15%;text-align:right;">修改人：</td>
	    <td><input type="text" value="${reports.updator}" readonly="readonly" name="updator" class="textBox length-middle"/></td>
   		<td style="width:15%;text-align:right;">修改时间：</td>
	    <td><input type="datetime" value="<fmt:formatDate value="${reports.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" name="updateTime" class="textBox length-middle"/></td>
   </tr>
   <tr>
	    <td style="width:15%;text-align:right;"></td>
	    <td>
	     	<input type="submit" value="确认" class="tdBtn"/>
	    </td>
   </tr>
  </table>
  </form:form>
 </div>
</body>
</html>
<script type="text/javascript">
	function selImage(o) {
		document.getElementById("img").src = getFullPath(o);
	}

	function getFullPath(node){
	 var imgURL = "";
	    try{
	        var file = null;
	        if(node.files && node.files[0] ){
	            file = node.files[0];
	        }else if(node.files && node.files.item(0)) {
	            file = node.files.item(0);
	        }
	        //Firefox 因安全性问题已无法直接通过input[file].value 获取完整的文件路径
	        try{
	            //Firefox7.0
	            imgURL =  file.getAsDataURL();
	            //alert("//Firefox7.0"+imgRUL);
	        }catch(e){
	            //Firefox8.0以上
	            imgURL = window.URL.createObjectURL(file);
	            //alert("//Firefox8.0以上"+imgRUL);
	        }
	    }catch(e){      
	        //支持html5的浏览器,比如高版本的firefox、chrome、ie10
	        if (node.files && node.files[0]) {
	            var reader = new FileReader();
	            reader.onload = function (e) {
	                imgURL = e.target.result;
	            };
	            reader.readAsDataURL(node.files[0]);
	        }
	    }
	    return imgURL;
	}
</script>
<script type="text/javascript">
CKEDITOR.replace('reportContent', {
	"filebrowserUploadUrl" : "<%=request.getContextPath()%>/upload"
	});
</script>